package com.bcn.login_mybatisplus_demo.record.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.bcn.login_mybatisplus_demo.interceptor.AuthStorage;
import com.bcn.login_mybatisplus_demo.record.domain.TAppRecord;
import com.bcn.login_mybatisplus_demo.record.mapper.TAppRecordMapper;
import com.bcn.login_mybatisplus_demo.record.service.ITAppRecordService;
import com.bcn.login_mybatisplus_demo.util.Convert;
import com.bcn.login_mybatisplus_demo.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 人生历程Service业务层处理
 * 
 * @author administrator
 * @date 2025-03-11
 */
@Service
public class TAppRecordServiceImpl implements ITAppRecordService
{
    @Autowired
    private TAppRecordMapper tAppRecordMapper;

    /**
     * 查询人生历程
     * 
     * @param recordId 人生历程ID
     * @return 人生历程
     */
    @Override
    public TAppRecord selectTAppRecordById(Long recordId)
    {
        return tAppRecordMapper.selectTAppRecordById(recordId);
    }

    /**
     * 查询人生历程列表
     * 
     * @param tAppRecord 人生历程
     * @return 人生历程
     */
    @Override
    public List<TAppRecord> selectTAppRecordList(TAppRecord tAppRecord)
    {
        tAppRecord.setUserId(AuthStorage.getUser().getId());
        return tAppRecordMapper.selectTAppRecordList(tAppRecord);
    }

    /**
     * 新增人生历程
     * 
     * @param tAppRecord 人生历程
     * @return 结果
     */
    @Override
    public int insertTAppRecord(TAppRecord tAppRecord)
    {

        tAppRecord.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        tAppRecord.setUserId(AuthStorage.getUser().getId());
        return tAppRecordMapper.insertTAppRecord(tAppRecord);
    }

    /**
     * 修改人生历程
     * 
     * @param tAppRecord 人生历程
     * @return 结果
     */
    @Override
    public int updateTAppRecord(TAppRecord tAppRecord)
    {
        return tAppRecordMapper.updateTAppRecord(tAppRecord);
    }

    /**
     * 删除人生历程对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteTAppRecordByIds(String ids)
    {
        return tAppRecordMapper.deleteTAppRecordByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除人生历程信息
     * 
     * @param recordId 人生历程ID
     * @return 结果
     */
    @Override
    public int deleteTAppRecordById(Long recordId)
    {
        return tAppRecordMapper.deleteTAppRecordById(recordId);
    }
}
